// pages/personal/wallet/tx.js
const app = getApp()
const info = {}
Page({
    data: {

    },
    onLoad: function (options) {
        app.http.get('member/tixian').then(res => {
            this.setData({ total: res.data })
        }).catch(err => {
            app.wxToast.error(err.message)
        })
    },

    onInput(e) {
        info[e.currentTarget.dataset.key] = e.detail.value
        console.log(info)
    },
    allTx() {
        this.setData({
            allMoney: this.data.total
        })
        info['money'] = this.data.total
    },
    submit() {
        if (!info.bank_name) {
            app.wxToast.error('请输入银行名称')
            return
        }
        if (!info.bank_num) {
            app.wxToast.error('请输入银行卡号')
            return
        }
        if (!info.money) {
            app.wxToast.error('请输入提现金额')
            return
        }
        info.money = parseFloat(info.money)
        if (info.money <= 0 || info.money > +this.data.total) {
            app.wxToast.error('请输入正确的提现金额')
            return
        }

        wx.showLoading({
            title: '加载中...',
        })
        app.http.post('member/tixian', {
            data: Object.assign(info, { type: 2 })
        }).then(res => {
            wx.hideLoading()
            wx.showModal({
                title: '提示',
                content: '提现申请已提交，请等待后台管理员处理',
                showCancel: false,
                success: res => {
                    wx.navigateBack({

                    })
                }
            })
        }).catch(err => {
            app.wxToast.error(err.message)
        })
    },
})